﻿
Public Class RoseLine
    Inherits WindBase
    Public VisibleRoseLine As Boolean = True    '玫瑰线是否可见

    Public m_SolidBrush1 As SolidBrush = New SolidBrush(Color.White)
    Public m_SolidBrush2 As SolidBrush = New SolidBrush(Color.Black)

    Public Sub Draw(ByVal grap As Graphics, ByVal ArryWindRose() As Double, ByVal Location As PointF, ByVal m_RoseCheck As Boolean)
        PenProperty.Width = PenProperty.Width * PannelSetting.gScale / PannelSetting.PreScale '当比例发生变化时需要高速画笔的宽度
        Dim m_Pen As New Pen(Color.FromArgb(PenProperty.color))
        m_Pen.DashStyle = PenProperty.DashStyle
        m_Pen.Width = PenProperty.Width

        Dim ArryAnomaly(2) As PointF '用来存储一个图形的数据

        '画风玫瑰图，
        Dim mScale As Double
        If m_RoseCheck = True Then
            mScale = 10
        Else
            mScale = 22.5
        End If
        Dim ArryRose(ArryWindRose.Length - 1) As PointF '16个方位/360度的风玫瑰数组
        ArryRose(0).X = 0 + Location.X
        ArryRose(0).Y = ArryWindRose(0) * Math.Sin((90 - mScale * 0) * Math.PI / 180) + Location.Y

        '填充玫瑰图
        If Visible Then
            Dim i As Integer = 1
            For i = 1 To ArryWindRose.Length - 2
                '用红画玫瑰图
                ArryRose(i).X = ArryWindRose(i) * Math.Cos((90 - mScale * i) * Math.PI / 180) + Location.X
                ArryRose(i).Y = ArryWindRose(i) * Math.Sin((90 - mScale * i) * Math.PI / 180) + Location.Y
                '用图形做玫瑰图
                ArryAnomaly(0).X = 0 + Location.X
                ArryAnomaly(0).Y = 0 + Location.Y
                ArryAnomaly(1).X = ArryRose(i - 1).X
                ArryAnomaly(1).Y = ArryRose(i - 1).Y
                ArryAnomaly(2).X = ArryRose(i).X
                ArryAnomaly(2).Y = ArryRose(i).Y
                If i Mod 2 = 0 Then
                    grap.FillPolygon(m_SolidBrush1, ArryAnomaly)
                Else
                    grap.FillPolygon(m_SolidBrush2, ArryAnomaly)
                End If
            Next
            ArryRose(ArryWindRose.Length - 1).X = 0 + Location.X
            ArryRose(ArryWindRose.Length - 1).Y = ArryWindRose(0) * Math.Sin((90 - mScale * 0) * Math.PI / 180)
            ArryAnomaly(1).X = ArryRose(i - 1).X
            ArryAnomaly(1).Y = ArryRose(i - 1).Y
            ArryAnomaly(2).X = 0 + Location.X
            ArryAnomaly(2).Y = ArryRose(0).Y
            grap.FillPolygon(m_SolidBrush1, ArryAnomaly)
        End If

        '用线画玫瑰图
        If VisibleRoseLine Then
            Dim i As Integer = 1
            For i = 1 To ArryWindRose.Length - 2
                '用红画玫瑰图
                ArryRose(i).X = ArryWindRose(i) * Math.Cos((90 - mScale * i) * Math.PI / 180) + Location.X
                ArryRose(i).Y = ArryWindRose(i) * Math.Sin((90 - mScale * i) * Math.PI / 180) + Location.Y
                '用图形做玫瑰图
                ArryAnomaly(0).X = 0 + Location.X
                ArryAnomaly(0).Y = 0 + Location.Y
                ArryAnomaly(1).X = ArryRose(i - 1).X
                ArryAnomaly(1).Y = ArryRose(i - 1).Y
                ArryAnomaly(2).X = ArryRose(i).X
                ArryAnomaly(2).Y = ArryRose(i).Y
                grap.DrawLines(m_Pen, ArryAnomaly)
            Next
            ArryRose(ArryWindRose.Length - 1).X = 0 + Location.X
            ArryRose(ArryWindRose.Length - 1).Y = ArryWindRose(0) * Math.Sin((90 - mScale * 0) * Math.PI / 180)
            ArryAnomaly(1).X = ArryRose(i - 1).X
            ArryAnomaly(1).Y = ArryRose(i - 1).Y
            ArryAnomaly(2).X = 0 + Location.X
            ArryAnomaly(2).Y = ArryRose(0).Y
            grap.DrawLines(m_Pen, ArryAnomaly)
        End If
    End Sub
End Class
